﻿using System.Web.Http;
using System.Web.Http.Dispatcher;
using System.Web.Http.ModelBinding;
using FlitBit.Dto.Mvc.WebApi;
using FlitBit.Wireup;

namespace FlitBit.Dto.Mvc
{
    public sealed class AssemblyWireupWebApiModelBinderProvider : IWireupCommand
    {
        public void Execute(IWireupCoordinator coordinator)
        {
            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), new WebApiDtoHttpControllerActivator());
            GlobalConfiguration.Configuration.Services.Insert(typeof(ModelBinderProvider), 0, new WebApiDtoModelBinderProvider());
        }
    }
}